<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"> 
<meta content="yes" name="apple-mobile-web-app-capable"> 
<meta content="black" name="apple-mobile-web-app-status-bar-style"> 
<meta content="telephone=no" name="format-detection"> 
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<link rel="stylesheet" type="text/css"
	href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="static/easyui/themes/icon.css">
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="static/jqueryValidate/jquery.validate.min.js"></script>
<script src="static/jqueryValidate/additional-methods.min.js"></script>
<script src="static/jqueryValidate/localization/messages_zh.min.js"></script>
  <title>首页</title>
</head>
<body class="easyui-layout">

	<div data-options="region:'center'" title="项目列表">
		<table id="pro_table" class="easyui-datagrid" style="height: 100%">
		</table>
	</div>
	<div id="pro_tb">
		<div>
			起始日期：<input id="startdate" class="easyui-datebox" /> 终止日期： <input
				id="enddate" class="easyui-datebox" /> <a href="#"
				class="easyui-linkbutton" iconCls="icon-search" onclick="search()">搜索</a>
		</div>
	</div>
</body>
<script>
	var currentPro;
	var startdate = ""; 
	var enddate = ""; 
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "level3/projectitems.do",
			method : 'get',
			queryParams : {
				startdate : startdate,
				enddate : enddate
			},
			onSelect : function(index, row) {
				currentPro = row;
			},
			onClickRow : function(index, row) {
				window.location.href="appindex.html";
			},
			columns : [ [ {
				field : 'name',
				title : '项目名',
				width : '250px'
			}, {
				field : 'projectno',
				title : '立项号',
				width : '250px'
			}, {
				field : 'startdate',
				title : '开始日期',
				width : '250px',
				formatter : formatDate
			}, {
				field : 'enddate',
				title : '结束日期',
				width : '250px',
				formatter : formatDate
			}, {
				field : 'projectaddr',
				title : '施工地址',
				width : '250px'
			}, {
				field : 'companymoney',
				title : '项目预决算',
				width : '250px',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="companymoney()">项目预决算</a>'
				}
			} , {
				field : 'compactmoney',
				title : '汇总预决算',
				width : '250px',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="compactmoney()">汇总预决算</a>'	
				}
			}] ]
		});
	});

	
	function refreshProTable() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "level3/projectitems.do",
			method : 'get',
			queryParams : {
				startdate : startdate,
				enddate : enddate
			},
			onSelect : function(index, row) {
				currentPro = row;
			},
			onClickRow : function(index, row) {
				window.location.href="appindex.html";
			},
			columns : [ [ {
				field : 'name',
				title : '项目名',
				width : '250px'
			}, {
				field : 'projectno',
				title : '立项号',
				width : '250px'
			}, {
				field : 'startdate',
				title : '开始日期',
				width : '250px',
				formatter : formatDate
			}, {
				field : 'enddate',
				title : '结束日期',
				width : '250px',
				formatter : formatDate
			}, {
				field : 'projectaddr',
				title : '施工地址',
				width : '250px'
			}, {
				field : 'companymoney',
				title : '项目预决算',
				width : '250px',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="companymoney()">项目预决算</a>'	
				}
			} , {
				field : 'compactmoney',
				title : '汇总预决算',
				width : '250px',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="compactmoney()">汇总预决算</a>'	
				}
			}] ]
		});
	}
	
	function search() {
		startdate = $("#startdate").datebox('getValue');
		enddate = $("#enddate").datebox('getValue');
		refreshProTable();
	}
	
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(), month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(), hour = date.getHours(), min = date.getMinutes(), sec = date
				.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
	
</script>
</html>